﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Oxage.Midi
{
	public class MidiInfo
	{
		#region Properties
		public static List<string> Families
		{
			get
			{
				List<string> list = new List<string>();
				list.Add("(all available)"); //1-128
				list.Add("Piano"); //1-8
				list.Add("Chromatic Percussion"); //9-16
				list.Add("Organ"); //17-24
				list.Add("Guitar"); //25-32
				list.Add("Bass"); //33-40
				list.Add("Strings"); //41-48
				list.Add("Ensemble"); //49-56
				list.Add("Brass"); //57-64
				list.Add("Reed"); //65-72
				list.Add("Pipe"); //73-80
				list.Add("Synth Lead"); //81-88
				list.Add("Synth Pad"); //89-96
				list.Add("Synth Effects"); //97-104
				list.Add("Ethnic"); //105-112
				list.Add("Percussive"); //113-120
				list.Add("Sound Effects"); //121-128
				return list;
			}
		}

		public static List<string> Instruments
		{
			get
			{
				//List from: http://www.midi.org/techspecs/gm1sound.php
				List<string> list = new List<string>();
				list.Add("Acoustic Grand Piano");
				list.Add("Bright Acoustic Piano");
				list.Add("Electric Grand Piano");
				list.Add("Honky-tonk Piano");
				list.Add("Electric Piano 1");
				list.Add("Electric Piano 2");
				list.Add("Harpsichord");
				list.Add("Clavi");
				list.Add("Celesta");
				list.Add("Glockenspiel");
				list.Add("Music Box");
				list.Add("Vibraphone");
				list.Add("Marimba");
				list.Add("Xylophone");
				list.Add("Tubular Bells");
				list.Add("Dulcimer");
				list.Add("Drawbar Organ");
				list.Add("Percussive Organ");
				list.Add("Rock Organ");
				list.Add("Church Organ");
				list.Add("Reed Organ");
				list.Add("Accordion");
				list.Add("Harmonica");
				list.Add("Tango Accordion");
				list.Add("Acoustic Guitar (nylon)");
				list.Add("Acoustic Guitar (steel)");
				list.Add("Electric Guitar (jazz)");
				list.Add("Electric Guitar (clean)");
				list.Add("Electric Guitar (muted)");
				list.Add("Overdriven Guitar");
				list.Add("Distortion Guitar");
				list.Add("Guitar harmonics");
				list.Add("Acoustic Bass");
				list.Add("Electric Bass (finger)");
				list.Add("Electric Bass (pick)");
				list.Add("Fretless Bass");
				list.Add("Slap Bass 1");
				list.Add("Slap Bass 2");
				list.Add("Synth Bass 1");
				list.Add("Synth Bass 2");
				list.Add("Violin");
				list.Add("Viola");
				list.Add("Cello");
				list.Add("Contrabass");
				list.Add("Tremolo Strings");
				list.Add("Pizzicato Strings");
				list.Add("Orchestral Harp");
				list.Add("Timpani");
				list.Add("String Ensemble 1");
				list.Add("String Ensemble 2");
				list.Add("SynthStrings 1");
				list.Add("SynthStrings 2");
				list.Add("Choir Aahs");
				list.Add("Voice Oohs");
				list.Add("Synth Voice");
				list.Add("Orchestra Hit");
				list.Add("Trumpet");
				list.Add("Trombone");
				list.Add("Tuba");
				list.Add("Muted Trumpet");
				list.Add("French Horn");
				list.Add("Brass Section");
				list.Add("SynthBrass 1");
				list.Add("SynthBrass 2");
				list.Add("Soprano Sax");
				list.Add("Alto Sax");
				list.Add("Tenor Sax");
				list.Add("Baritone Sax");
				list.Add("Oboe");
				list.Add("English Horn");
				list.Add("Bassoon");
				list.Add("Clarinet");
				list.Add("Piccolo");
				list.Add("Flute");
				list.Add("Recorder");
				list.Add("Pan Flute");
				list.Add("Blown Bottle");
				list.Add("Shakuhachi");
				list.Add("Whistle");
				list.Add("Ocarina");
				list.Add("Lead 1 (square)");
				list.Add("Lead 2 (sawtooth)");
				list.Add("Lead 3 (calliope)");
				list.Add("Lead 4 (chiff)");
				list.Add("Lead 5 (charang)");
				list.Add("Lead 6 (voice)");
				list.Add("Lead 7 (fifths)");
				list.Add("Lead 8 (bass + lead)");
				list.Add("Pad 1 (new age)");
				list.Add("Pad 2 (warm)");
				list.Add("Pad 3 (polysynth)");
				list.Add("Pad 4 (choir)");
				list.Add("Pad 5 (bowed)");
				list.Add("Pad 6 (metallic)");
				list.Add("Pad 7 (halo)");
				list.Add("Pad 8 (sweep)");
				list.Add("FX 1 (rain)");
				list.Add("FX 2 (soundtrack)");
				list.Add("FX 3 (crystal)");
				list.Add("FX 4 (atmosphere)");
				list.Add("FX 5 (brightness)");
				list.Add("FX 6 (goblins)");
				list.Add("FX 7 (echoes)");
				list.Add("FX 8 (sci-fi)");
				list.Add("Sitar");
				list.Add("Banjo");
				list.Add("Shamisen");
				list.Add("Koto");
				list.Add("Kalimba");
				list.Add("Bag pipe");
				list.Add("Fiddle");
				list.Add("Shanai");
				list.Add("Tinkle Bell");
				list.Add("Agogo");
				list.Add("Steel Drums");
				list.Add("Woodblock");
				list.Add("Taiko Drum");
				list.Add("Melodic Tom");
				list.Add("Synth Drum");
				list.Add("Reverse Cymbal");
				list.Add("Guitar Fret Noise");
				list.Add("Breath Noise");
				list.Add("Seashore");
				list.Add("Bird Tweet");
				list.Add("Telephone Ring");
				list.Add("Helicopter");
				list.Add("Applause");
				list.Add("Gunshot");
				return list;
			}
		}
		#endregion

		#region Methods
		public static byte[] NoteOff(byte channel, byte data)
		{
			byte status = (byte)(0x80 | channel);
			byte[] result = { status, data, 0x40 };
			return result;
		}

		public static byte[] NoteOn(byte channel, byte data)
		{
			byte status = (byte)(0x90 | channel);
			byte[] result = { status, data, 0x40 };
			return result;
		}

		public static byte[] ProgramChange(byte channel, byte data)
		{
			byte status = (byte)(0xC0 | channel);
			byte[] result = { status, data };
			return result;
		}

		public static byte[] Aftertouch(byte channel, byte data)
		{
			byte status = (byte)(0xA0 | channel);
			byte[] result = { status, data };
			return result;
		}
		#endregion
	}
}
